Make add_bytes() work with raw blocks#334
Open
ProximaNova wants to merge 2 commits intoipfs-shipyard:masterfrom
Open
Make add_bytes() work with raw blocks#334ProximaNova wants to merge 2 commits intoipfs-shipyard:masterfrom
ProximaNova wants to merge 2 commits intoipfs-shipyard:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
It would be nice if add_bytes() had some more functionality. This pull request (PR) adds a bit more functionality to it. This adds function
add_raw_bytes()which is basicallyadd_bytes()except with this call to the HTTP/RPC API:return self._client.request('/add?cid-version=1&chunker=size-1048576',It is worth explaining similar pull requests or issues here. Both of the following are more ambitious ideas which are like making parts of the code a Swiss Army Knife (for it to do many more things instead of the one/few things it currently does):
#288 titled "add_str() and add() do not take the same optional parameters". Ideally, add(), add_str(), and add_bytes() would all have the maximum amount of optional arguments, or at least each one would be able to add raw blocks. #288 is a short thread.
#287 titled "add optional arguments to add_str()" (long/longer thread). https://github.com/ipfs-shipyard/py-ipfs-http-client/pull/287/files looks great (I guess, didn't run personally that code)! Why was it not accepted!? @ntninja said "we'll probably complete this eventually." - that didn't happen. @ftyers seemed to have gotten embarrassed and was shy and therefore closed the PR, so that kinda killed enthusiasm for it.
My motivation for writing this is partly this issue -- oduwsdl/ipwb#853 -- however, I do think this is generally beneficial. The code I request to be merged here is solid and it does work. It is simple and adds a bit more useful functionality, so I think it would pass automated tests. add() can add raw blocks, but why shouldn't add_bytes() also be able to do that? I think they're used in different contexts, like add() only works on file objects and add_bytes() only works on streams/stdin/pipe (non-file things).
Edit 1: "minor" fixes. Edit 2: same.